#ifndef __ANALYSIS_H__
#define __ANALYSIS_H__

#include "Include.h"
#include "FitMethods/Include.h"
#include "EfficCalcMethods/Include.h"
#include "Painting.h"
#include "IOmanager.h"
#include "AnalysisResult.h"

#include <vector>
#include <algorithm>

class Analysis
{
    public:
        /** Constructs an object that will perform the Analysis as specified by the given AnalysisConfig object */
        Analysis(AnalysisConfig c) {
            config = c;
        }
        ~Analysis() {
            gc.collect();
        }
    private:
        /** Analysis is not designed to be copy constructed, or copied for that matter. Use the public constructor on the same AnalysisConfig object
         * to produce an equivalent analysis. */
        Analysis(const Analysis & c);
        Analysis & operator=(const Analysis & c);

    public:
        /** AnalysisConfig object config stores ALL configuration parameters for this analysis. */
        AnalysisConfig config;
        
    public:
        /** Use runAnalysis() to perform the actual calculations. */
        void runAnalysis();

    private:
        GarbageCollector gc; //< This objects garbage collector.
        /** The following vectors store templates used during the analysis*/
        vector <TH1D *> probeBgdTempl, selectedBgdTempl, probeSigTempl,
               selectedSigTempl;
        TH1D * probeData, * selectedData;
    private:
        TH1D * getHistogram(HistogramConfig h);
        void loadHistograms(const vector <HistogramConfig> & templateConfigVector, vector <TH1D *> & resultVector);
};

#endif
